package config

import java.io.File

object Global extends MyFile {

  val isWindow: Boolean = {
    System.getProperties.getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1
  }

  def getLogByPath(path:String):String = {
    val log = s"$path/log.txt".readLines
    var html =
      """
        |<style>
        |   .logClass{
        |       font-size : 16px;
        |       font-weight:normal;
        |   }
        |</style>
      """.stripMargin
    html += "<b class='logClass'>" + log.mkString("</b><br><b class='logClass'>") + "</b>"
    html
  }


  def random :String = {
    val source = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
    var value = ""
    for (i <- 0 to 20){
      val ran = Math.random()*62
      val char = source.charAt(ran.toInt)
      value += char
    }
    value
  }

  val windowsPath = "I:/hordeum_db"
  val linuxPath = new File("../").getAbsolutePath

  val testResult = windowsPath + "/testResult"

  val path: String = {
    if (isWindow) windowsPath else linuxPath
  }

  val Rscript = "/mnt/sdb/xwq/tools/R-4.0.2/bin/Rscript"

  val suffix: String = {
    if (new File(windowsPath).exists()) ".exe" else " "
  }

  val tmpPath: String = s"$path/tmp"

  val toolsPath: String = s"$path/tools"

  def samtools:String = if(isWindow) s"$toolsPath/samtools-0.1.19/samtools.exe" else "samtools"

  val enrichPath: String = path + "/enrichData/"

}
